package project.euler.honk.problem.to50;

public final class Problem17 {

	public static int  solve() {
		int[] oners = new int[9];
		oners[0] = "one".length();
		oners[1] = "two".length();
		oners[2] = "three".length();
		oners[3] = "four".length();
		oners[4] = "five".length();
		oners[5] = "six".length();
		oners[6] = "seven".length();
		oners[7] = "eight".length();
		oners[8] = "nine".length();

		int[] teners = new int[9];
		teners[0] = 0;
		teners[1] = "twenty".length();
		teners[2] = "thirty".length();
		teners[3] = "forty".length();
		teners[4] = "fifty".length();
		teners[5] = "sixty".length();
		teners[6] = "seventy".length();
		teners[7] = "eighty".length();
		teners[8] = "ninety".length();

		int[] strange = new int[9];
		strange[0] = "eleven".length();
		strange[1] = "twelve".length();
		strange[2] = "thirteen".length();
		strange[3] = "fourteen".length();
		strange[4] = "fifteen".length();
		strange[5] = "sixteen".length();
		strange[6] = "seventeen".length();
		strange[7] = "eighteen".length();
		strange[8] = "nineteen".length();

		int[] hundreds = new int[9];
		for (int i = 0; i < 9; i++)
			hundreds[i] = oners[i] + "hundred".length();

		int sum = 0;
		for (int i = 0; i < 9; i++) {
			sum += 100 * hundreds[i];
			sum += 99 * "and".length();
			sum += 90 * oners[i];
			sum += 100 * teners[i];
			sum += 10 * strange[i];
		}
		sum += 10 * "ten".length();
		sum += "onethousand".length();
		return sum;
	}
	
	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		long result = solve();
		long end = System.currentTimeMillis();
		System.out.println("Result: " + result + " Time: " + (end - start));
	}

}
